// 调试;
// ---如何调试组合函数;

// const _ = require("lodash");

// const f = _.flowRight(_.toUpper, _.first, _.reverse);

// console.log(f(["one", "two", "three"]));

//函数组合-- - 调式
//NEVER  SAY  DIE    ==>   never-say-die

const _ = require("lodash");

//调式函数
const log = (v) => {
  console.log(v);
  return v;
};

const trace = _.curry((tag, v) => {
  console.log(tag, v);
  return v;
});

//sep代表分隔符    str传入的字符串
//这样写的目的是先传入一个参数
const split = _.curry((sep, str) => _.split(str, sep));

// _.toLower

//sep代表分隔符    array代表数组
const join = _.curry((sep, array) => _.join(array, sep));

const map = _.curry((fn, array) => _.map(array, fn));

const f = _.flowRight(
  join("-"),
  trace("map 之后"),
  // log,
  //   _.toLower,
  map(_.toLower), //改造
  trace("split 之后"),
  // log,
  split(" ")
);

console.log(f("NEVER SAY DIE"));
